package com.haidechizi.i18n.common.enums;

import java.util.Objects;

/**
 * 多语言对应的枚举
 */
public enum LanguageTypeEnum {

    zh_CN("zh_CN", "简体中文"),
    zh_TW("zh_TW", "繁体中文(台湾)"),
    zh_HK("zh_HK", "繁体中文(香港)"),
    en_US("en_US", "美式英语");

    private String code;
    private String desc;

    LanguageTypeEnum(String code, String desc) {
        this.code = code;
        this.desc = desc;
    }

    public static LanguageTypeEnum getLanguageByCode(String code) {
        LanguageTypeEnum[] values = LanguageTypeEnum.values();
        for (LanguageTypeEnum typeEnum : values) {
            if (Objects.equals(typeEnum.code, code)) {
                return typeEnum;
            }
        }
        return null;
    }

    public String getCode() {
        return code;
    }

    public void setCode(String code) {
        this.code = code;
    }

    public String getDesc() {
        return desc;
    }

    public void setDesc(String desc) {
        this.desc = desc;
    }
}
